import moment from "moment";
export const addCategoryOpptions = (arr, addOpptions) => {
  const updatedData = arr.map((subArray) =>
    subArray.map((item) =>
      item.name === "category" ? { ...item, options: addOpptions } : { ...item }
    )
  );
  return updatedData;
};
//时间戳转时间
export function formatTime(time, formatStr = "YYYY-MM-DD HH:mm:ss") {
  if (!time) return "-";
  const _time = parseInt(time);
  if (isNaN(_time)) {
    return "-";
  }
  return moment(_time).format(formatStr);
}
// 字符串转数组
export function strToArr(str) {
  if (typeof str !== "string") return [];
  return str.split(",")
}